package com.example.czxyindex.web;

import com.example.czxyindex.web.remote.IBuyAction;
import com.yc.czxy.bean.Buy;
import com.yc.czxy.bean.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: chengzixy
 * @description:求购操作
 * @author: 刘志成
 * @create: 2021-08-31 22:46
 */
@Controller
public class BuyAction {


    @Resource
    IBuyAction iBuyAction;
    /**
     * 添加求购
     * @return
     */
    @PostMapping("addBuy")
    @ResponseBody
    public Result<Buy> addBuy(Buy buy) {
        return iBuyAction.addBuy(buy);
    }

    /**
     * 删除商品
     * @return
     */
    @PostMapping("deleteBuyBybid")
    @ResponseBody
    public Result<Buy> deleteBuyBybid(Buy buy) {
        return iBuyAction.deleteBuyBybid(buy);
    }


    /**
     * 根据用户id查询所拥有的求购
     * @param uid
     * @return
     */
    @GetMapping("selectBuyByUid")
    @ResponseBody
    public List<Buy> selectBuyByUid(Integer uid){
        List<Buy> buy = iBuyAction.selectBuyByUid(uid);
        return buy;
    }

    @GetMapping({"buy","/"})
    public String buy() {
        return "buy";
    }

}
